* Replication script

* Get the data (merged from Haffert's data and the SCoRE data, see www.score.uni-mainz.de)

use catholics-afd-replication , replace

* Run full models at the municipality, Kreis (county) & electoral district levels


* Municipalities

melogit afd i.F4 i.male i.higheduc i.agecat i.serviceman i.relig##i.prussia##c.catholic_share c.unemployment c.empl_marginal c.empl_regular c.population_1000 i.university c.foreign_share c.pop65_share c.female_share i.border_district || munic: ,vce(cluster munic)

capture drop insample
gen insample = e(sample)
est store full
estimates save full, replace



* Kreis / county 

melogit afd i.F4 i.male i.higheduc i.agecat i.serviceman i.relig##c.prussia_k##c.catholic_share_k c.unemployment_k c.empl_marginal_k c.empl_regular_k c.population_1000_k c.university_k c.foreign_share_k c.pop65_share_k c.female_share_k c.border_district_k if insample  || kreis: ,vce(cluster kreis)
est store full_k
estimates save full_k, replace

* Interactions still jointly insignificant

test 2.relig#c.prussia_k#c.catholic_share_k 1.relig#c.prussia_k#c.catholic_share_k c.prussia_k#c.catholic_share_k 2.relig#c.catholic_share_k 1.relig#c.catholic_share_k 2.relig#c.prussia_k 1.relig#c.prussia_k


* Districts

melogit afd i.F4 i.male i.higheduc i.agecat i.serviceman i.relig##c.prussia_wk##c.catholic_share_wk c.unemployment_wk c.empl_marginal_wk c.empl_regular_wk c.population_1000_wk c.university_wk c.foreign_share_wk c.pop65_share_wk c.female_share_wk c.border_district_wk if insample || wk_nr: ,vce(cluster wk_nr)
est store full_wk
estimates save full_wk, replace 

test 2.relig#c.prussia_wk#c.catholic_share_wk 1.relig#c.prussia_wk#c.catholic_share_wk c.prussia_wk#c.catholic_share_wk 2.relig#c.catholic_share_wk 1.relig#c.catholic_share_wk 2.relig#c.prussia_wk 1.relig#c.prussia_wk

* Still jointly insignificant

esttab full full_k full_wk using table-1-main-text.rtf , drop(*.F4 0.* *#0*)  scalars(N_clust) nomtitles label  replace se compress 

